<?php
/**
 * Created by PhpStorm.
 * User: zhangligang
 * Date: 2018/4/9
 * Time: 上午1:01
 */

if (! function_exists('local_date')) {
    function local_date($date, $format = 'Y-m-d')
    {
        return date($format, strtotime($date));
    }
}

if (! function_exists('get_date_year')) {
    function get_date_year($date = null) {
        if (!$date) {
            $date = time();
        }
        $s = explode(' ', date('Y-m-d H:i:s', $date));
        $s1 = explode('-', $s[0]);
        return $s1[0];
    }
}

if (! function_exists('age')) {
    function age($birthday) {
        return (int)((time() - strtotime($birthday)) / (3600 * 24 * 365));
    }
}

if (! function_exists('gender')) {
    function gender($gender) {
        switch ($gender) {
            case 0: return '未知';
            case 1: return '男';
            case 2: return '女';
            case 3: return '保密';
        }
        return '保密';
    }
}


if (! function_exists('education')) {
    function education($education) {
        switch ($education) {
            case 0: return '';
            case 1: return '高中';
            case 2: return '高职';
            case 3: return '专科';
            case 4: return '本科';
            case 5: return '硕士';
            case 6: return '博士';
            case 7: return '其他';
            default:return '';
        }
    }
}

if (! function_exists('get_role_name')) {
    function get_role_name($role)
    {
        switch ($role) {
            case 1 : return '教学人员';
            case 2 : return '科研人员';
            case 3 : return '管理人员';
            case 4 : return '教辅人员';
            case 5 : return '学生';
        }
        return '教学人员';
    }
}
